package com.hdu.dwh.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hdu.dwh.pojos.SubjectTableSource;
import com.hdu.dwh.mapper.SubjectTableSourceMapper;
import com.hdu.dwh.service.ISubjectTableSourceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 主题数据表与源表关联表 服务实现类
 * </p>
 *
 * @author bobo
 * @since 2025-04-08
 */
@Service
public class SubjectTableSourceServiceImpl extends ServiceImpl<SubjectTableSourceMapper, SubjectTableSource> implements ISubjectTableSourceService {

    @Override
    public boolean deleteBySubjectTableIds(List<Long> id) {
        if(id != null){
            LambdaQueryWrapper<SubjectTableSource> queryWrapper = new LambdaQueryWrapper<SubjectTableSource>()
                    .in(SubjectTableSource::getSubjectTableId, id);
            if(count(queryWrapper)==0){
                return true;
            }
            return remove(queryWrapper);
        }
        return true;
    }

    @Override
    public boolean deleteBySubjectTableId(Long id) {
        if(id != null){
            LambdaQueryWrapper<SubjectTableSource> queryWrapper = new LambdaQueryWrapper<SubjectTableSource>()
                    .eq(SubjectTableSource::getSubjectTableId, id);
            if(count(queryWrapper)==0){
                return true;
            }
            return remove(queryWrapper);
        }
        return true;
    }
}
